package com.pwrd.sframe;

import com.pwrd.sframe.netty.ConnServer;
import com.pwrd.sframe.core.Node;
import com.pwrd.game.service.GateService;
import com.pwrd.sframe.support.constant.ConfigConst;
import com.pwrd.sframe.core.Port;
import com.pwrd.sframe.core.obverser.RemoteCallObverserInit;
import com.pwrd.sframe.support.constant.ConstNode;


/**
 * @Auther syc.
 * @Date 2017/1/10 14:29.
 */
public class ConnsrvStartup {

    public static void main(String[] args) {

        // Init obverser
        RemoteCallObverserInit.init();

        Node connNode = new Node(ConstNode.NODE_DEFAULT);
        // Start the threads which receive the msg from the connection server received.
        for(int i = 0; i < ConfigConst.PORT_STARTUP_CONN_NUM; i++) {
            String portKey = ConstNode.PORT_CONN_PREFIX + i;
            Port port = new Port(portKey);
            port.startup(connNode);
        }

        // Start the connection server
        ConnServer.startUp(connNode);

        // Start the game server
        Node gameNode = connNode;
        Port gamePort = new Port(ConstNode.PORT_DEFAULT);
        gamePort.startup(gameNode);

        // Start the gate service
        new GateService(gamePort).startUp();
    }
}
